/*
    Copyright 2012 Sven-Ove Bjerkan

    This file is part of KO-Ozi.

    KO-Ozi is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    KO-Ozi is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with KO-Ozi. If not, see <http://www.gnu.org/licenses/>.
*/
package com.koozi.backup;

import com.koozi.Settings;
import com.koozi.TimeAndDate;

/**
 * Class that handles backup of tracks/waypoints
 * @author Sven-Ove Bjerkan
 */
public class Backup implements Runnable {
    private Zip zip;
    private Settings settings;
    
    public Backup() {
        settings = Settings.getInstance();
    }
    
    @Override
    public void run() {
        zip = new Zip();
        
        // Loop and creates a backup in given interval
        while (!Thread.interrupted()) {
            try {
                Thread.sleep(settings.getBackupInterval() * 60 * 1000);
                zip.compress("kl " + TimeAndDate.getNiceTime(".") + ".zip", false);
            } catch (InterruptedException ex) {
                
            }
        }
    }
    
}
